#!/usr/bin/env bash
#安装odoo
yum clean all
yum update
yum install libstdc++.i686
yum install -y postgresql postgresql-server postgresql-libs
postgresql-setup initdb
systemctl enable postgresql
systemctl start postgresql
su - postgres
#psql
#postgres=# \password postgres
#postgres=# \q
#exit
yum install -y epel-release
yum install -y yum-utils
yum-config-manager --add-repo=https://nightly.odoo.com/8.0/nightly/rpm/odoo.repo
yum install -y odoo
systemctl enable odoo
systemctl start odoo

#防火墙设置
firewall-cmd --zone=public --add-port=21/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=8069/tcp --permanent
firewall-cmd --zone=public --add-port=5901/tcp --permanent
#SVN
firewall-cmd --zone=public --add-port=3690/tcp --permanent
firewall-cmd --zone=public --add-port=65432/tcp --permanent
firewall-cmd --zone=public --add-port=5432/tcp --permanent
#shadowsocks
firewall-cmd --zone=public --add-port=8112/tcp --permanent		
firewall-cmd --zone=public --add-port=873/tcp --permanent #Rsync
firewall-cmd --zone=public --add-port=2121-2131/tcp --permanent
firewall-cmd --reload

#时区设置
timedatectl set-timezone Asia/Shanghai

#安装rsync
yum -y install xinetd rsync
systemctl enable xinetd.service
service xinetd restart
systemctl enable rsyncd
systemctl start rsyncd
useradd -d /home -s /sbin/nologin kaikong
passwd kaikong
chown -R kaikong:kaikong /home
cat kaikong:kaikong >/etc/rsync.pass
chmod 600 /etc/rsync.pass

#安装shadowsocks
yum install -y gcc automake autoconf libtool make build-essential curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel git
#(zlib-devel openssl-devel 安装不上,需要再次单独安装)
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
./configure && make
make install
mkdir -p /etc/shadowsocks
systemctl start shadowsocks-server.service
systemctl enable shadowsocks-server.service

#搭建SVN服务器
yum install -y subversion
#查看安装版本 
svnserve --version
#创建SVN版本库目录 
mkdir -p /home/svn
#创建版本库  
svnadmin create /home/svn/altium.svn
#启动svn版本库  
svnserve -d -r /home/svn
#（停止SVN命令  killall svnserve ,命令未发现）

#SVN库同步
#初始化,注意不要有盘符
E:\>svnsync.exe init svn://192.168.31.10/altium.svn file:///svn --sync-username kaikong --sync-password kaikong51291968
#同步
svnsync.exe sync svn://192.168.31.10/altium.svn --sync-username kaikong --sync-password kaikong51291968


#搭建git服务器
yum – y install git
#创建一个裸仓库
#cd /home
#mkdir git
#cd git
#git init --bare project.git
#.创建一个git用户，git登陆上传走的貌似好像就是ssh，所以要创建一个用户
#useradd git
#passwd git
#然后把project.git文件夹赋予git用户
#chown -R git:git project.git

#搭建Apache、MySQL、PHP
yum install -y php mariadb mariadb-server php-mysql 
#安装PHP扩展组件
yum install -y php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc 
#安装MySQL扩展组件
yum install -y mysql-connector-odbc mariadb-devel libdbi-dbd-mysql 
#启动MySQL，注意Centos7使用systemctl整合了以前使用的chkconfig和service，具体可以查看Centos7的systemctl使用，还要注意服务名称是mariadb
systemctl enable mariadb.service
systemctl start mariadb.service 
#设置MySQL管理员密码
mysqladmin -uroot password kaikong51291968 
mysql_secure_installation
mysql -u root -p
#CREATE DATABASE a1217134857;
#use a1217134857;
#source /home//web/localhost.sql;
# CREATE USER a1217134857@localhost IDENTIFIED BY '3ab8cc75';
#insert into mysql.user(Host,User,Password) values('localhost','a1217134857',password('3ab8cc75'));
#update mysql.user set password=password('3ab8cc75') where User='a1217134857' and Host='localhost';
#grant all  on a1217134857.* to a1217134857@localhost identified by 'a1217134857';
#quit
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload


